package com.xiangyang.pos.adapter;

import android.content.Context;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import com.xiangyang.pos.R;
import com.xiangyang.pos.bean.GetOrderDataBean;

import java.util.List;

/**
 * Created by Administrator on 2017/12/5 0005.
 */

public class OrderGetGoodsShopIdAdapter extends RecyclerView.Adapter<OrderGetGoodsShopIdAdapter.ViewHolder> {

    private List<GetOrderDataBean.ShopData> content;
    private Context context;

    private GetOrderAdapter adapter;

    public OrderGetGoodsShopIdAdapter(List<GetOrderDataBean.ShopData> content, Context context) {
        this.content = content;
        this.context=context;
    }

    @Override
    public ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {

        View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_sure_order_sohpid, parent, false);
        ViewHolder viewHolder = new ViewHolder(view);

        return viewHolder;
    }

    @Override
    public void onBindViewHolder(ViewHolder holder, int position) {

        holder.tvShop.setText(content.get(position).getTitle()+"("+content.get(position).getAddress()+")");

        LinearLayoutManager manager=new LinearLayoutManager(context);
        manager.setOrientation(LinearLayoutManager.VERTICAL);
        holder.recycler.setLayoutManager(manager);

        adapter=new GetOrderAdapter(content.get(position).getShopgoods(),context);
        holder.recycler.setAdapter(adapter);


    }

    @Override
    public int getItemCount() {
        return content.size();
    }

    public class ViewHolder extends RecyclerView.ViewHolder {


        private TextView tvShop;
        private RecyclerView recycler;

        public ViewHolder(View itemView) {
            super(itemView);

            tvShop = itemView.findViewById(R.id.tv_shop);
            recycler = itemView.findViewById(R.id.recycler);

        }
    }


}
